#include <iostream>
using namespace std;
class Animal
{
public:
	Animal(int _num)
	{
		num=_num;
		cout<<"父类有参数构造  "<<_num<<endl;
	}
	Animal()
	{
		cout<<"父类无参构造"<<endl;
	}
	~Animal()
	{
		cout<<"父类析构"<<endl;
	}
private:
	int num;
	
};

class Dog:public Animal
{
public:
	Dog()
	{
		cout<<"子类无参构造"<<endl;
	}
	Dog(int _age)
	{
		age=_age;
		cout<<"子类有参构造"<<endl;
	}
	~Dog()
	{
		cout<<"子类析构"<<endl;
	}
private:
	int age;
};

int main()
{
	//定义一个Dog对象
	Dog dog1;  //先构建父类对象的一个副本，然后在创建子类对象
	Dog dog2(8);
}